package com.witdata.common.domain.dto;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.witdata.common.serializer.ToLongDeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class InstanceDto implements Serializable{
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonDeserialize(using = ToLongDeSerializer.class)
    private Long id;
    private String name;
    private String ip;
    private Status status;
    @JSONField(name = "total_memory")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long totalMemory;
    @JsonSerialize(using = ToStringSerializer.class)
    @JSONField(name = "used_memory")
    private Long usedMemory;
    private Integer memoryUsage;
    private LocalDateTime created;
    private LocalDateTime updated;

    public enum Status {
        Normal,
        Online,
        Offline,
    }
}
